<?php
/*里昂工作室www.leonhere.com*/
if(isset($_SERVER['SCRIPT_FILENAME']) && 'comments.php' == basename($_SERVER['SCRIPT_FILENAME']))
die('please do not load this page directly. Thanks!');
if ( have_comments() ) {
?>
<section class="commentsList">
	<h3 class="posttitle">最新评论</h3>
	<?php if ( post_password_required() ) {?>
	<ol>
		<li>
			<p>请输入密码再查看评论内容.</p>
		</li>
	</ol>
  	<?php 
		return; 
		}
	?>
	<ol>
		<?php wp_list_comments('type=comment&callback=leonhere_comment');?>
	</ol>
	<?php 
		if (get_option('page_comments')) {
			$comment_pages = paginate_comments_links('echo=0');
			if ($comment_pages) {
				echo '<div class="pagenavi">';
				echo $comment_pages;
				echo '</div>';
			}
		}	
	?>
</section>
<?php } ?>

<div class="commentForm">
	<h3 class="posttitle">我要评论</h3>
	<?php if (get_option('comment_registration') && !is_user_logged_in()) : ?>
	<div class="warning">你必须 <a href="<?php echo wp_login_url( get_permalink() ); ?>">登录</a> 才能发表评论。</div>
	<?php else : ?>
	<div id="respond">
		<form id="commentform" name="commentform" action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post">
			<div class="item">
				<label>内容：</label>
				<div class="input">
					<textarea name="comment" class="text" id="comment" tabindex="1"></textarea>
				</div>
			</div>
			<?php if(is_user_logged_in()) :?>
	      	<div class="warning">登录用户：<a href="<?php echo get_option('siteurl'); ?>/wp-admin/profile.php"><?php echo $user_identity; ?></a>。 点击 <a href="<?php echo wp_logout_url(get_permalink()); ?>" title="退出登录">退出</a> 登陆</div>
	    	<?php else : ?>
			<div class="item d-none">
				<label>昵称：</label>
				<div class="input">
					<input type="text" name="author" id="author" class="text" value="冬瓜网友" tabindex="2"/>
				</div>
			</div>
			<div class="item d-none">
				<label>邮箱：</label>
				<div class="input">
					<input type="text" name="email" class="text" id="email" value="abc@qq.com" tabindex="3" placeholder="(保密)"/>
				</div>
			</div>
			<div class="item d-none">
				<label>网址：</label>
				<div class="input">
					<input type="text" name="url" class="text" value="<?php home_url(); ?>" tabindex="4"/>
				</div>
			</div>
			<?php endif; ?>
			<div class="btn">
				<input type="submit" name="submit" class="submit" value="提交" tabindex="5"/>
				<?php cancel_comment_reply_link('取消'); ?>
			</div>
			<?php comment_id_fields(); ?>
			<?php do_action('comment_form',$post->ID);?>
		</form>
	</div>
	<?php endif; ?>
</div>